@extends('layout.master')

@section('title','普通商户权限设置')

@section('css')
    @parent
    <!-- animation CSS -->
    <style>
        .form-material .form-group.stySelect {
            overflow: visible;
        }

        .form-material button.form-control {
            padding: .8rem 25px .8rem 1.2rem;
            border: 1px solid #e4e7ea;
        }

        .dropify-wrapper {
            border: 0;
        }
    </style>
@endsection
@section('main')
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <form class="form-horizontal form-material" id="editadmin" method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">初始名称</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $config->title }}" name="title"
                                           class="form-control form-control-line">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1">
                            <div class="form-group">
                                <label class="col-md-12">圈子数量</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $config->circle }}" name="circle"
                                           class="form-control form-control-line">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1">
                            <div class="form-group">
                                <label class="col-md-12">医生上限</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $config->docnum }}" name="docnum"
                                           class="form-control form-control-line">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1">
                            <div class="form-group">
                                <label class="col-md-12">展示数量</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $config->shownum }}" name="shownum"
                                           class="form-control form-control-line">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">优惠券记录</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $config->coupon }}" name="coupon"
                                           class="form-control form-control-line">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">聊天记录保留时间（天）</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $config->keeptime }}" name="keeptime"
                                           class="form-control form-control-line">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1">
                            <div class="form-group">
                                <label class="col-md-12">查看患者详情</label>
                                <select class="form-control column_filter" name="scanuser">
                                    <option value='0' @if($config->scanuser === 0) selected @endif>不能</option>
                                    <option value='1' @if($config->scanuser === 1) selected @endif>能</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-1">
                            <div class="form-group">
                                <label class="col-md-12">能否群发</label>
                                <select class="form-control column_filter" name="qunsend">
                                    <option value='0' @if($config->qunsend === 0) selected @endif>不能</option>
                                    <option value='1' @if($config->qunsend === 1) selected @endif>能</option>
                                </select>
                            </div>
                        </div>

                    </div>
                    <div class="form-group">
                        <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="edit-config">更新信息
                        </button>
                        {!! csrf_field() !!}
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
@section('js')
    @parent
    <script type="text/javascript">


        $('#edit-config').click(function (e) {
            e.preventDefault();
            swal({
                    title: "",
                    text: "确定修改么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/shop/config',
                        data: $('#editadmin').serialize(),// 你的formid
                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            for (var j in err.responseJSON) {
                                err.responseJSON[j].forEach(function (item, index) {
                                    swal(item);
                                })
                            }
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
    </script>
@endsection